import platform

if platform.system() == "Windows":
    import asyncio

    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())


import tornado
import tornado.ioloop
import tornado.web

from QualityInspectionViolation.Controller.ViolationController import ViolationHandler, AppealHandler, CallHandler, \
    MenuHandler, ShareHandler, SecondShareHandler, DepartmentHandler, MenuSynchronizationHandler, \
    RoleSynchronizationHandler, RoleSynchronizationAsyncHandler, RoleSynchronizationAsyncioHandler
from QualityInspectionViolation.DbInit.mysqlDb import init_db


def make_app():
    return tornado.web.Application([
        (r"/reviewAppeal", ViolationHandler),
        (r"/insertAppealService", AppealHandler),
        (r"/queryMenu", MenuHandler),
        (r"/callOut", CallHandler),
        (r"/share", ShareHandler),
        (r"/secondShare", SecondShareHandler),
        (r"/roleSynchronization", RoleSynchronizationHandler),
        (r"/roleSynchronizationAsync", RoleSynchronizationAsyncHandler),
        (r"/roleSynchronizationAsyncio", RoleSynchronizationAsyncioHandler),
        (r"/menuSynchronization", MenuSynchronizationHandler),
        (r"/department", DepartmentHandler),
    ])

if __name__ == "__main__":

    init_db()

    app = make_app()
    app.listen(2037)
    tornado.ioloop.IOLoop.current().start()